package com.sky.service.impl;

import com.sky.service.ShopService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class ShopServiceImpl implements ShopService {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    /**
     * 设置营业状态
     * @param status
     */
    @Override
    public void updateStatus(Integer status) {
        //构建key
        String key = "SHOP_STATUS";
       //新增缓存数据
        stringRedisTemplate.opsForValue().set(key, String.valueOf(status));
    }

    /**
     * 查询营业状态
     *
     * @return
     */
    @Override
    public Integer getStatus() {
        //构建key
        String key = "SHOP_STATUS";
        //查询redis缓存
        String value = stringRedisTemplate.opsForValue().get(key);
        Integer status = Integer.valueOf(value);
        return status;
    }
}
